package com.goldenlight.fvms.manager.filter;

import java.util.ArrayList;
import java.util.List;

public class FilterChain implements Filter{
    private List<Filter> filterList = new ArrayList<>();

    private int index;

    public FilterChain addFilter(Filter filter) {
        this.filterList.add(filter);
        return this;
    }

    public void doFilter(Request request, Response response, FilterChain filterChain) {
        if(index == filterList.size()) return ;
        filterList.get(index++).doFilter(request, response, filterChain);
    }

}
